<?php

/**
 * Created by PhpStorm.
 * User: fanfz_000
 * Date: 2015/4/6 0006
 * Time: 19:24
 * 作用 ：标签控制器
 */
class Label extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
    }
    //
    //word,label_id详细信息
    function label_for_word($label_id, $word_id = 0)
    {
        //缓存60分钟更新一次
        $this->output->cache(60);

        //模型操作，图片轮播图片列表
        $this->load->model('Backgroudurl_model', 'image', TRUE);
        $data['image_list'] = $this->image->show_image_list();

        //模型操作,标签云
        $this->load->model('Label_model', 'label', TRUE);
        $data['label_list'] = $this->label->show_label_list();

        //模型操作,文章
        $this->load->model('Word_model', 'word', TRUE);
        $data['word_info'] = $this->word->label_for_word_info($label_id, $word_id);

        //模型操作,文章列表
        $data['word_list'] = $this->word->show_word_list(0, 30);

        //模型操作,友情链接
        $this->load->model('Friendhref_model', 'friend_href', TRUE);
        $data['friend_list'] = $this->friend_href->show_friend_href_list();

        //页面加载
        $this->load->view('header', $data);
        $this->load->view('word_header');
        $this->load->view('word_list');
        $this->load->view('word_aside');
        $this->load->view('footer');
    }
    function create_label()
    {
        $label_name = $this->input->post('label_name');
        $this->load->model('Label_model', 'label', TRUE);
        $data = $this->label->insert_label($label_name);
        echo json_encode($data);
    }

    function reset_label()
    {
        $label_name = $this->input->post('label_name');
        $Id = $this->input->post('Id');
        $this->load->model('Label_model', 'label', TRUE);
        $data = $this->label->update_label($Id, $label_name);
        echo json_encode($data);
    }

    function show_label_list()
    {
        $this->load->model('Label_model', 'label', TRUE);
        $data = $this->label->show_label_list();
        echo json_encode($data);
    }

    function show_label_info()
    {
        $page = $this->input->post('page');
        $limit = $this->input->post('limit');
        $this->load->model('Label_model', 'label', TRUE);
        $data = $this->label->show_label_list_info($page, $limit);
        echo json_encode($data);
    }

    function delete_label()
    {
        $label_id = $this->input->post('Id');
        $this->load->model('Label_model', 'label', TRUE);
        $data = $this->label->delete_label($label_id);
        echo json_encode($data);
    }
}